package com.ly.order.producer;

import com.common.core.text.UUID;
import com.domain.Order;
import com.ass.rocketmq.constant.MQTopic;
import com.ass.rocketmq.producer.AbstractDefaultProducer;
import lombok.Getter;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Log4j2
public class OrderProducer1 extends AbstractDefaultProducer<Order> {

    @Getter
    private final MQTopic mqTopic = MQTopic.TEST;


    @Getter
    private final String instanceName = "test_producer_1";


    //子类实现由调用者调用
    public void sendMsg(){
        log.info("备用生产者发送");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Order order = new Order()
                .setId(UUID.randomUUID().toString())
                .setDate(sdf.format(new Date()))
                .setNum("1");
        super.send(order.getId(), order);
    }

}
